<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function sleep(milliseconds) {
  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > milliseconds){
      break;
    }
  }
}

function submitAll(){
	return false
	var myForm = document.getElementsByTagName('form');
	for(i = 0; i < myForm.length;i++){
		myForm[i].submit();
	}
}

</script>
<!--<input type="button" onClick="submitAll()" value="Submit">-->
<hr>
<?php
require('dbconnect.php');
$limit = 40;
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$offset = ($page-1)*$limit;
$sqlView = "SELECT SQL_CALC_FOUND_ROWS * FROM data ORDER BY id DESC LIMIT $offset,$limit";

if($rs = mysql_query($sqlView)){
	$rsRow = mysql_query('SELECT FOUND_ROWS() as total');
	$total = mysql_fetch_array($rsRow);	echo '<ol>';
	#echo $total['total'];die;
	$totalPage = ceil($total['total']/$limit);

	$i = 1;
	while($row = mysql_fetch_array($rs)){
		if(trim($row['post_title']) != ''){
			echo '<li><iframe width="223" id="target_'.$i.'" name="target_'.$i.'" height="40" border="0" frameborder="1" scrolling="auto" align="center" hspace="0" vspace=""></iframe><form id="frm_'.$i.'" action="http://caigithe.com/crawler.php" method="post" target="target_'.$i.'"><input type="text" name="title" value="'.$row['post_title'].'"><input type="hidden" name="hashcode" value="'.$row['post_unique'].'"><br><input type="text" name="image" value="'.$row['post_image'].'">&nbsp;<input type="submit" value="Submit '.$i.'"><img src="'.$row['post_image'].'"" height="200">
			
			</form><script>
			var myForm = document.getElementById("frm_'.$i.'");
			myForm.submit();
			</script></li>';
			$i++;
		}
	}
	echo '</ol>';
}
for($i = 1; $i <= $totalPage; $i++){
	echo "<a href='?page=$i'>$i</a> ";
}
?>
<!--
<hr>
<input type="button" onClick="submitAll()" value="Submit">
-->
